package vista;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import controlador.Sistema;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AltaIncidente extends javax.swing.JFrame {
	private JLabel lblNum;
	private JLabel lblDNI;
	private JLabel lblEstado;
	private JButton btnCancelar;
	private JButton btnAceptar;
	private JTextField txtEstado;
	private JTextField txtDNI;
	private JTextField txtNum;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	public AltaIncidente() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			this.setTitle("Alta incidente");
			{
				lblNum = new JLabel();
				getContentPane().add(lblNum);
				lblNum.setText("Numero: ");
				lblNum.setBounds(48, 36, 85, 14);
			}
			{
				lblDNI = new JLabel();
				getContentPane().add(lblDNI);
				lblDNI.setText("DNI: ");
				lblDNI.setBounds(48, 87, 85, 14);
			}
			{
				lblEstado = new JLabel();
				getContentPane().add(lblEstado);
				lblEstado.setText("Estado");
				lblEstado.setBounds(48, 146, 85, 14);
			}
			{
				txtNum = new JTextField();
				getContentPane().add(txtNum);
				txtNum.setBounds(173, 37, 164, 21);
			}
			{
				txtDNI = new JTextField();
				getContentPane().add(txtDNI);
				txtDNI.setBounds(173, 88, 164, 21);
			}
			{
				txtEstado = new JTextField();
				getContentPane().add(txtEstado);
				txtEstado.setBounds(173, 147, 164, 21);
			}
			{
				btnAceptar = new JButton();
				getContentPane().add(btnAceptar);
				btnAceptar.setText("Aceptar");
				btnAceptar.setBounds(97, 203, 97, 21);
				btnAceptar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						Sistema.getInstancia().crearIncidente(Integer.parseInt(txtNum.getText()), txtDNI.getText(),txtEstado.getText());
						limpiar();
					}
				});
			}
			{
				btnCancelar = new JButton();
				getContentPane().add(btnCancelar);
				btnCancelar.setText("Cancelar");
				btnCancelar.setBounds(208, 203, 97, 21);
				btnCancelar.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						dispose();
					}
				});
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

	public void limpiar(){
		txtDNI.setText("");
		txtEstado.setText("");
		txtNum.setText("");
	}
}
